package org.grayrabbit.cloud.core.biz;

import org.grayrabbit.cloud.core.rpc.Result;

public class BizResult implements Result {
	private static final long serialVersionUID = -5262812959804131474L;
	public static final BizResult TRUE = new BizResult(Boolean.TRUE);
	public static final BizResult FALSE = new BizResult(Boolean.FALSE);
	public static final BizResult NULL = new BizResult(null);
	private Object result;

	private BizResult(Object result) {
		this.result = result;
	}

	public Object getResult() {
		return result;
	}

	public static BizResult create(Object result) {
		return new BizResult(result);
	}

	public String toString() {
		if ((this.result != null) && ((this.result instanceof Throwable))) {
			return String.format("BizResult:{%s}",
					new Object[] { Thrower.toString((Throwable) this.result) });
		}
		return String.format("BizResult:{%s}", new Object[] { this.result });
	}

	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if ((obj instanceof BizResult)) {
			BizResult o = (BizResult) obj;
			if (this.result == null)
				return o.result == null;
			return this.result.equals(o.result);
		}
		return false;
	}

}
